//
//  WBFooterView.swift
//  SainMicroblog
//
//  Created by chenxinju on 16/5/7.
//  Copyright © 2016年 chenxinju-a2. All rights reserved.
//

import UIKit

//字体大小
let WBOrginalFontMargin: CGFloat = 16

class WBFooterView: UIView {
    
  //拥有模型属性
    var footerViewModel: WBStatusViewModel? {
        
       //重写模型属性赋值
        didSet {
          retweetButton.setTitle(footerViewModel?.reposts_String, forState: UIControlState.Normal)
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        //backgroundColor = UIColor.blueColor()
        
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    
    //添加子控件布局
    func setupUI() {
        addSubview(retweetButton)
        addSubview(commentButton)
        addSubview(goodButton)
///  转发
        retweetButton.snp_makeConstraints { (make) -> Void in
         make.left.equalTo(self.snp_left)
         make.top.equalTo(self.snp_top)
        make.right.equalTo(commentButton.snp_left)
        make.bottom.equalTo(self.snp_bottom)
          
            //设置宽度
            make.width.equalTo(commentButton.snp_width)
        }
        
 /// 评论
        commentButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(self.snp_top)
            make.right.equalTo(goodButton.snp_left)
            make.bottom.equalTo(self.snp_bottom)
      //设置宽度
        make.width.equalTo(goodButton.snp_width)
        }
        
 /// 点赞数
        goodButton.snp_makeConstraints { (make) -> Void in
         make.top.equalTo(self.snp_top)
         make.right.equalTo(self.snp_right)
         make.bottom.equalTo(self.snp_bottom)
            
        }
        
    }
    
    
    //MARK:- 懒加载控件
    private lazy var retweetButton:UIButton = {
        let retButton = UIButton()
        
        retButton.setTitle("转发", forState: UIControlState.Normal)
        
        retButton.setTitleColor(UIColor.darkGrayColor(), forState: UIControlState.Normal)
        
        retButton.setImage(UIImage(named: "timeline_icon_retweet"), forState: UIControlState.Normal)
        //设置字体大小
        retButton.titleLabel?.font = UIFont.systemFontOfSize(WBOrginalFontMargin)
        
        return retButton
    }()
    
    ///  评论
    private lazy var commentButton:UIButton = UIButton(title: "评论", image: "timeline_icon_comment", Color: UIColor.darkGrayColor(), size: WBOrginalFontMargin)
    ///  点赞
    private lazy var goodButton:UIButton = UIButton(title: "点赞", image: "timeline_icon_like", Color: UIColor.darkGrayColor(), size: WBOrginalFontMargin)
}
